﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AIProject.Pylos
{
    class Action
    {
        private Move[] moves;
        private int cost;

        public Move this[int i]
        {
            get
            {
                if (i < 3 && i >= 0)
                {
                    return this.moves[i];
                }
                else
                {
                    return null;
                }
            }
            set
            {
            }
        }

        public int Cost
        {
            get
            {
                return this.cost;
            }
            set
            {
            }
        }

        public Action(Move[] moves)
        {
            this.moves = moves;
            this.cost = 1;
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        public override Boolean Equals(Object obj)
        {
            if (obj == null)
            {
                return false;
            }

            Action otherAction = obj as Action;

            if (otherAction == null)
            {
                return false;
            }
            else
            {
                for (int i = 0; i < 3; i++)
                {
                    if (this[i] != null)
                    {
                        if (!this[i].Equals(otherAction[i]))
                        {
                            return false;
                        }
                    }
                    else
                    {
                        return otherAction[i] == null;
                    }
                }
                return true;
            }
        }
    }
}
